package com.proyecto.track.action;

import java.util.*;

import com.opensymphony.xwork2.ActionSupport;
import com.proyecto.track.bo.ItemAutoComplete;
import com.proyecto.track.bo.Project;
import com.proyecto.track.service.ProjectService;


public class ProjectAutoCompleteAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	
	private ProjectService projectService;
	private String term;
	private List<ItemAutoComplete> items = new ArrayList<ItemAutoComplete>();
	
	public String searchProjects() {
		List<Project> projects = projectService.searchProjects(term);
		for (Project project : projects) {
			items.add(new ItemAutoComplete(project.getId(), project.getName(), project.getName()));			
		}
		return SUCCESS;
	}
	
	
	public ProjectService getProjectService() {
		return projectService;
	}
	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}
	public String getTerm() {
		return term;
	}
	public void setTerm(String term) {
		this.term = term;
	}
	public List<ItemAutoComplete> getItems() {
		return items;
	}
	public void setItems(List<ItemAutoComplete> items) {
		this.items = items;
	}

}
